package net.simflow.swf.analyzer.gui.ginfo.generator;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

import net.simflow.swf.analyzer.bgnetwork.data.BGNode;
import net.simflow.swf.analyzer.bgnetwork.stats.data.BGNetworkStats;
import net.simflow.swf.analyzer.data.StringConstant;
import net.simflow.swf.analyzer.data.TupleStrInt;
import net.simflow.swf.analyzer.stringtrans.BGOneStatsStringGenerator;

public class BGOneGenerator {
	protected final static LinkedHashMap<String, Boolean> DEFAULT_CONFIG = new LinkedHashMap<String, Boolean>();
	static {
		DEFAULT_CONFIG.put(BGNetworkStats.ONE_GRAPH_NAME, true);
		DEFAULT_CONFIG.put(BGNetworkStats.ONE_NEIGHBOR, true);
	}

	private static BGOneGenerator instance = new BGOneGenerator();

	private BGOneGenerator() {
	}

	public static BGOneGenerator getInstance() {
		return instance;
	}

	public ArrayList<TupleStrInt> generate(String name, BGNode node) {
		if (name == null || node == null) {
			return null;
		}

		ArrayList<TupleStrInt> info = new ArrayList<TupleStrInt>();
		for (Entry<String, Boolean> en : DEFAULT_CONFIG.entrySet()) {
			if (!en.getValue()) {
				continue;
			}

			ArrayList<TupleStrInt> tmp = null;
			String style = en.getKey();
			tmp = BGOneStatsStringGenerator.getInstance().generate(style, name,
					node);

			if (tmp != null && tmp.size() > 0) {
				info.addAll(tmp);
			}
		}
		if (info.size() > 0) {
			info.add(0, new TupleStrInt("Bipartite Graph",
					StringConstant.PKG_TITLE));
		}

		return info;
	}
}
